<!--#include file="UpLoad_Class.asp"-->
<!-- #include file="conn.asp" -->

<%
Session.CodePage=65001
Response.Charset="utf-8"

sType = request("sType")
if (IsEmpty(request("id")) or request("id")="" ) then
	id=0
else
	id=cint(trim(request("id")))
end if

iconInfoName = trim(request("iconInfoName"))
iconInfoRoute = trim(request("iconInfoRoute"))
v1 = trim(request("v1"))

if sType = "add" then
	dim upload
	set upload = new AnUpLoad
	upload.Exe = "*"
	upload.MaxSize = 4 * 1024 * 1024 '2M
	upload.GetData()
	response.Write "in.....***" & upload.ErrorID
	if upload.ErrorID>0 then 
		response.Write upload.Description
	else
		dim savpath,sFileName,strResult
		for each f in upload.files(-1)
			dim file
			set file = upload.files(f)
			'set rs= server.createobject("adodb.recordset")
			
			fileExt=lcase(right(file.filename,4))
			foundsee=false
			seenameid=split("jpg|bmp|png|gif","|")
			seecount=ubound(seenameid)
			for j = 0 to seecount
			  if instr(fileExt,"."&seenameid(j))>0 then
				foundsee=true
				exit for
			 end if
			next
			response.Write "in.....111"
			if not foundsee then
				'response.write "<font size=3>文件格式不对,只能上传图片文件！jpg bmp png gif　[ <a href=# onclick=history.go(-1)>重新上传</a> ]</font>"
				strResult = 1
				exit for
			else
				'sFileName = lcase(left(file.filename,6))
				filename0=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)
				filename=filename0 & fileEXT
				sFileName= filename0 & fileEXT
				savepath = "upfile/"& sFileName
				response.Write "in.....222 = "& savepath
				if not(file is nothing) then
					result = file.saveToFile(savepath,0,true)
					if result then
'						if id>0 then    'update
'							'sql="update iconInfo set iconInfoName='"&iconInfoName&"',iconInfoRoute="&savepath&",v1="&v1&" where id="&id
'							'conn.execute(sql)
'							if err.number=0 then
'								strResult = 3
'							else
'								strResult = 4
'							end if
'						else
'							'sql="insert into iconInfo ([iconInfoName],[iconInfoRoute],[v1]) values ('"&iconInfoName&"','"&savepath&"','"&v1&"')"
'							'conn.execute(sql)
'							if err.number=0 then
'								strResult = 0
'							else
'								strResult = 1
'							end if
'						end if
						'response.Write "文件'" & file.LocalName & "'上传成功，保存位置'" & server.MapPath(savepath & "/" & file.filename) & "',文件大小" & file.size & "字节<br />"
					else
						strResult = 1
						exit for
					end if
				end if
			end if
			set file = nothing
			set rs = nothing
		next
		response.Write "{success:true,msg:"&strResult&"}"
	end if
	set upload = nothing

	
elseif sType = "del" then
	arrvalue=split(id,",")
    for i=0 to ubound(arrvalue)
      	on error resume next
	  	sql="delete from iconInfo where id=" & arrvalue(i)
		conn.execute(sql)
    next
else
end if

conn.close


%>